package com.mj.haier.calc.repository;

import com.mj.haier.calc.domain.ItfOutcomeStatmentDetailBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * Spring Data  repository for the ItfOutcomeStatmentDetailBean entity.
 */
@SuppressWarnings("unused")
@Repository
public interface ItfOutcomeStatmentDetailBeanRepository extends JpaRepository<ItfOutcomeStatmentDetailBean, Long> {

    @Query(nativeQuery = true,value = "select " +
        "t.id AS id," +
        "t.settle_batch_id AS doc_no," +
        "t.order_code AS order_no," +
        "t.product_name AS product_name," +
        "t.product_model_no AS product_version," +
        "t.source_name_code AS source_name_code," +
        "t.source_name AS source_name," +
        "'B01' AS account_type," +
        "t.server_close_time AS FINISH_DATE," +
        "0 AS transport_amt," +
        "0 AS install_amt," +
        "0 AS long_distance_amt," +
        "round(t.settle_operate_cost * 100) AS operate_amt," +
        "round(t.settle_service_type_cost * 100) AS service_type_amt," +
        "round(t.settle_traffic_cost * 100)  AS traffic_amt," +
        "round(t.settle_meterial_cost * 100) AS meterial_amt," +
        "round(t.settle_subidy_cost * 100) AS subidy_amt," +
        "round(t.settle_compensatory_cost * 100) AS compensatory_amt," +
        "round(t.settle_reward_cost * 100) AS reward_amt," +
        "SYSDATE() AS gmt_create," +
        "round(t.settle_fee_total_cost * 100) AS total_amt from az_fin_settle_bill t where t.settle_item = '1' and t.trade_code = ?1 AND t.settle_batch_id = ?2 ")
    List<ItfOutcomeStatmentDetailBean> findAllBySettleBatchId(String tradeCode, String settleBatchId);
}
